package cn.easyar.samples.helloarqrcode.util;


import android.content.Context;
import android.util.Log;

import cn.easyar.samples.helloarqrcode.MyApplication;


/**
 */
public class GlobalParams {

    public static final String phone = "opration_phone";
    public static final String password = "opration_password";



    public static void saveUserId(int userId) {
        SharedPreferencesUtil.saveIntData(MyApplication.applicationContext, "userId", userId);
    }

    public static void saveuser_token(String user_token) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "user_token", user_token);
    }

    public static String getuser_token() {
        String user_token = SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "user_token", "-1");
        return user_token;
    }

    public static int getUserId() {
        int userId = SharedPreferencesUtil.getIntData(MyApplication.applicationContext, "userId",-1);
        return userId;
    }
//    public static void savaUserBean(Context context, LoginBean bean) {
////        savaComplete(context, bean.complete);
////        savaVip(context, bean.vip);
//        saveUserId(bean.id);
////        savaUserType(context, bean.type);
//        savaUserName(bean.name);
//        saveuser_token(bean.token);
//        savaUsernicename(bean.nickname);
//
//    }


    public static void savaRoomId(String roomId) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "roomId", roomId);
    }
    public static String getRoomId() {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "roomId", "-1");
    }

    private static void savaUsernicename(String nickname) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "nickname", nickname);
    }
    public static String getUsernicename() {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "nickname", "-1");
    }

    private static void savaUserName(String name) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "name", name);
    }
    public static String getUserName() {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "name", "-1");
    }


    public static String getUserType(Context context) {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "userType", "-1");
    }
    public static String getUserType() {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "userType", "-1");
    }
    public static String getUserqust(Context context) {
        return SharedPreferencesUtil.getStringData(MyApplication.applicationContext,"qust","-1");
    }

    public static void saveUserqust(Context context, String count) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext,"qust",count);
    }


    public static void savaUserType(Context context, String type) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "userType", type);
    }
    public static void savaUserType(String type) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "userType", type);
    }



    /**
     * 获取List
     * @param tag
     * @return
     */
    public static String getDataList(String tag) {
        String strJson = SharedPreferencesUtil.getStringData(MyApplication.applicationContext, tag, "-1");

        return strJson;

    }


    public static String getToken() {
        return getuser_token();
    }
    public static Boolean isVip(Context context) {
        // 结束的时间
        String entTime = SharedPreferencesUtil.getStringData(MyApplication.applicationContext, "isvip", "-1");;
        Log.e("-----------------",entTime);
        //当前时间 小于vip时间 就是vip
        return  System.currentTimeMillis()/1000 < Long.parseLong(entTime);
    }
    //endTime 存到期的时间戳 (其实好像有点问题，就是过期的问题，扫后完善)
    public static void savaVip(Context context, String endTime) {
        SharedPreferencesUtil.saveStringData(MyApplication.applicationContext, "isvip", endTime);
    }
    public static Boolean isComplete(Context context) {
       return SharedPreferencesUtil.getBooleanData(MyApplication.applicationContext, "isComplete", false);
    }

}
